package cn.itcast.mq.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SpringRabbitListener {

    @RabbitListener(queues = "quorum.queue")
    public void listenSimpleQueue(String msg) {
        // 此时已经接收到了消息：
        log.debug("消费者接收到simple.queue的消息：【" + msg + "】");
        //模拟异常。 收到了消息，还没有消费消息：
       // System.out.println(1/0);
        // 消费消息 ：
        log.debug("消息已经消费完成了");
    }


/*
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "delay.queue",durable = "true"), //队列 durable持久
            exchange = @Exchange(name = "delay.direct",delayed = "true"), // 交换机延迟
            key = "delay"
    ))
    public void listenDelayExchange(String msg){
        log.info("消费者接收到了delay.exchange的延迟消息消息：{}",msg);
    }
*/

}

